//
//  Person.m
//  05_排序、数组字典的处理
//
//  Created by dllo on 16/7/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person
- (instancetype)initWithName:(NSString *)name age:(NSInteger)age sex:(NSString *)sex {
    self = [super init];
    if (self) {
        _name = name;
        _age = age;
        _sex = sex;
    }
    return self;
}
- (NSString *)description
{
    return [NSString stringWithFormat:@"%@, %ld, %@", _name, _age, _sex];
}
- (NSComparisonResult)compareByName:(Person *)anotherPerson {
    return [self.name compare:anotherPerson.name];
}
- (NSComparisonResult)compareByAge:(Person *)anotherPerson {
    return self.age > anotherPerson.age;
}
- (NSComparisonResult)compareBySex:(Person *)anotherPerson {
    return [self.sex compare:anotherPerson.sex];
}
@end
